package com.zzl.controller;



import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.system.common.pojo.BisBeautyRecord;
import com.zzl.service.BisBeautyRecordService;

@Controller
@RequestMapping("bbr")
public class BisBeautyRecordController {
	
	@Autowired
	private BisBeautyRecordService service;
	
	@RequestMapping("listbbr")
	public String listbbr(Model model,HttpServletRequest request,HttpServletResponse response)throws Exception {
		Map<String,Object> map=getParatems(request);
		List<BisBeautyRecord> list=service.select(map);
		model.addAttribute("list", list);
		return "/bis_cash/bbrList";
		}
/*		String[] title = {"��ˮ��","�������","�˿ͱ��","����","��ֵ����","ʵ�����ѽ��","����","֧��ʱ��"};

       //excel�ļ���
      String fileName = "��ֵ��ˮ��"+System.currentTimeMillis()+".xls";
//sheet��
      String sheetName = "��ֵ��ˮ��";
     
for (int i = 0; i < list.size(); i++) {

String[][] content = null;
content[i] = new String[title.length];
BisBeautyRecord bbr=list.get(i);
content[i][0] = bbr.getRecordId().toString();
content[i][1] = bbr.getOrderId().toString();
content[i][2] = bbr.getCustomUserId().toString();
content[i][3] = bbr.getCustomUserName().toString();
content[i][4] = bbr.getGiveNum().toString();
content[i][5] = bbr.getTotalMoney().toString();
content[i][6] = bbr.getRecordType().toString();
content[i][7] = bbr.getPayTime().toString();
//����HSSFWorkbook 
HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook(sheetName, title, content, null);
//��Ӧ���ͻ���
try {
this.setResponseHeader(response, fileName);
OutputStream os = response.getOutputStream();
wb.write(os);
os.flush();
os.close();
} catch (Exception e) {
e.printStackTrace();
}

}*/

	/*public void setResponseHeader(HttpServletResponse response, String fileName) {
        try {
            try {
                fileName = new String(fileName.getBytes(),"ISO8859-1");
            } catch (UnsupportedEncodingException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            response.setContentType("application/octet-stream;charset=ISO8859-1");
            response.setHeader("Content-Disposition", "attachment;filename="+ fileName);
            response.addHeader("Pargam", "no-cache");
            response.addHeader("Cache-Control", "no-cache");
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }*/
   
	private Map<String, Object> getParatems(HttpServletRequest reuest){
		Map<String,Object> map=new HashMap<>();
		String qorderId = reuest.getParameter("qorderId");
		if(qorderId!=null&&qorderId!=""){
			map.put("qorderId", qorderId);
		}
		String qcustomUserId = reuest.getParameter("qcustomUserId");
		if(qcustomUserId!=null&&qcustomUserId!=""){
			map.put("qcustomUserId", qcustomUserId);
		}
		String qcustomUserName = reuest.getParameter("qcustomUserName");
		if(qcustomUserName!=null&&qcustomUserName!=""){
			map.put("qcustomUserName", qcustomUserName);
		}
		String qrecordTypPpe = reuest.getParameter("qrecordTypPpe");
		if(qrecordTypPpe!=null&&qrecordTypPpe!=""){
			map.put("qrecordTypPpe", qrecordTypPpe);
		}
		String qstartTime = reuest.getParameter("qstartTime");
		if(qstartTime!=null&&qstartTime!=""){
			map.put("qstartTime", qstartTime);
		}
		String qendTime = reuest.getParameter("qendTime");
		if(qendTime!=null&&qendTime!=""){
			map.put("qendTime", qendTime); 
		}
		return map;
		
	}
}
